<%--
 *  File:    AgreementMain.jsp
 *  @Author: DC
 *  Date:    2011/09/13
 *
 *  Copyright (C) 2000 - 2001 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>

<%@ page import="java.text.*" %>
<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>



<% //--------------------------------------  setting logger --%>
<%
  Category cat = Category.getInstance("jsp.NewDeliveryMain");
  //init param
  String strModuleName = "CRM";
  String privilegeCode = "11206";
  //System.out.println("*************************"+privilegeCode);
  String contextPath = request.getContextPath();
%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<iframe name="reloadHandler" style="display:none" ></iframe>
<html>
<head>
<PageFlow:CheckPageFlow pageName="p_agreementmain"/>
<%--@ include file="/inc/CatchError.inc" --%>
<%
	//params
     String viewflag = "";

     if(pageContext.getAttribute("viewflag") != null&&((String)pageContext.getAttribute("viewflag")).equals("view")) {

           viewflag = "view";
     }
		
    String strIsDefault = null;
	String paraIsDefault = "";
	String isTdNeed = "td-text";
	if("Y".equals(request.getParameter("isdefault"))) {
		strIsDefault = "&isdefault=Y";
		paraIsDefault = "Y";
		isTdNeed = "need";
	}else if ("N".equals(request.getParameter("isdefault"))) {
		strIsDefault = "&isdefault=N";
		paraIsDefault = "N";
	}
  String isNew = request.getParameter("isNew");
  if("Y".equals(request.getParameter("isNew"))) {
		isNew = "Y";
	}else if ("N".equals(request.getParameter("isNew"))) {
		isNew = "N";
	}else  {
		isNew = null;
	}
  //params end
  
  HashMap zmylagreementinfo = null;
  String valuezmylagreementid = null;
  String dateOpt = null;
  zmylagreementinfo = (HashMap)pageContext.getAttribute("zmylagreementinfo");
	  if(zmylagreementinfo != null&&zmylagreementinfo.size()!=0) {
  		if(isNew!=null && isNew.equals("Y")){
		  valuezmylagreementid = JspHelper.filterNull( zmylagreementinfo.get("zmylagreementid") ).toString();
	  	}
		dateOpt = JspHelper.filterNull( zmylagreementinfo.get("createdate") ).toString();
      }else {
	  	  zmylagreementinfo = new HashMap();
		  zmylagreementinfo.put("status",new Integer(10));
		  zmylagreementinfo.put("createdate",new java.sql.Date(System.currentTimeMillis()));
		  pageContext.setAttribute("zmylagreementinfo",zmylagreementinfo);
		  valuezmylagreementid = "";
		  zmylagreementinfo = (HashMap)pageContext.getAttribute("zmylagreementinfo");
      }
  HashMap userinfo = (HashMap)session.getAttribute("userinfo");
  
  
  
	String dateFormat = (String)session.getAttribute("dateformat");
	if(dateFormat==null)dateFormat = "yyyy-MM-dd";
  
%>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="../../css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="../../js/ScriptLib.js"></script>
<%@ include file ="/inc/NewCalendar.inc" %>
<script language="JavaScript">




function changeStatus()
{
  if(cform.status1.value == -1)
  {
	  cform.valuename.value = " ";
  }
  else
  {
	 // alert("status1 : " + cform.status1.value);
    for (i = 0; i < cform.status1.options.length; ++i)
    {
      var opt = cform.status1.options[i];
      if (opt.selected)
      {
    	  cform.valuename.value = opt.text;
      }
    }
  }
}

function changeProcessType()
{
  if(cform.processtype.value == -1)
  {
	  cform.groupname.value = " ";
  }
  else
  {
    for (i = 0; i < cform.processtype.options.length; ++i)
    {
      var opt = cform.processtype.options[i];
      if (opt.selected)
      {
    	  cform.groupname.value = opt.text;
      }
    }
  }
}

function page_save()
{	
	if(!checkForm(cform))   return;
	emptyToNull(cform);
	/*if(isEmpty(cform.processname.value)) {
		alert("<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_zmylagreementName",false)) %>");
		return;
	}
	if(isEmpty(cform.status.value)) {
		alert("<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_Status",false)) %>");
		return;
	}

	if( "Y" == "<%=paraIsDefault%>") {
		if(isEmpty(cform.processtype.value)) {
		alert("<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_Type",false)) %>");
		return;
		}
	}*/

	var startdates=document.cform.startdates.value;
	var expiredates=document.cform.expiredates.value;
	var datelastupdateds=document.cform.datelastupdateds.value;
	var startdate=document.cform.startdate.value;
	var expiredate=document.cform.expiredate.value;
	var signdate=document.cform.signdate.value;

	if(startdate!=null && startdate<startdates){
		alert("协议生效日期不能早于"+startdates);
		document.cform.startdate.select();
		return ;
	}
   if(startdate!=null && startdate>expiredates){
		alert("协议生效日期不能晚于"+expiredates);
		document.cform.startdate.select();
		return ;
	}
	if(expiredate!=null && expiredate<startdates){
		alert("协议结束日期不能早于"+startdates);
		document.cform.expiredate.select();
		return ;
	}
	if(expiredate!=null && expiredate>expiredates){
		alert("协议结束日期不能晚于"+expiredates);
		document.cform.expiredate.select();
		return ;
	}
	if (toDate(cform.startdate.value, '<%= session.getAttribute("dateformat") %>') > toDate(cform.expiredate.value, '<%= session.getAttribute("dateformat") %>')) {
          alert("<%= message.getMessageDesc("AgreementConfig_StartDate_Later_Than_Expiredate") %>");
         document.cform.startdate.focus();
     return;
     }

	if(signdate!=null && signdate>datelastupdateds){
		alert("签订日期不能大于"+datelastupdateds);
		document.cform.signdate.select();
		return ;
	}
	
	var  amount = Number(document.cform.amount.value);
	var quartersales1=Number(document.cform.quartersales1.value);
	var quartersales2=Number(document.cform.quartersales2.value);
	var quartersales3=Number(document.cform.quartersales3.value);
	var quartersales4=Number(document.cform.quartersales4.value);

	var tolquartersales=quartersales4+quartersales3+quartersales2+quartersales1;

	if(amount != tolquartersales){
		alert("协议额不等于分季度额之和！");
		return ;
		}
	
	var frm = document.cform;
	frm.actionname.value = "save";
	frm.target = "_parent";
	frm.submit();
}
function page_submit()
{
	if(!checkForm(cform))   return;

   if ( ! confirm("<%= message.getMessageDesc("ARE_YOU_SURE") %>") )  return;
	var frm = document.cform;
	frm.actionname.value = "submit";
	frm.target = "_parent";
	frm.submit();
}
function page_back()
{  
  parent.location.href = "AgreementManagement.jsp?<%= OvalTools.randomURL() %>&languagecode=<%= strLanguageCode%><%=JspHelper.filterNull( strIsDefault )%>";
}

function page_selectaction()
{
  var zmylagreementid = document.cform.zmylagreementid.value;
  if(zmylagreementid==null || zmylagreementid==""){
     alert("<%= message.getMessageDesc("SAVE_INFO_FIRST") %>");
     return;
  }
  if(popwindow!=null)
    popwindow.close();
  var zmylagreementid = document.cform.zmylagreementid.value;
  popwindow = window.open('<%=contextPath%>/devlop/sfe/VisitProcess4CustomerType.jsp?maxitem=12&languagecode=<%= strLanguageCode%>&<%= OvalTools.randomURL() %>&zmylagreementid='+zmylagreementid,'newwindow', 'height=400, width=850,top=150,left=300,toolbar=n0, menubar=no, scrollbars=auto, resizable=yes, location=no, status=no');
}

function set_orgNameByPopWindow(id,code,name){

     idObj=document.getElementById("zmylprodgroupid");
    nameObj=document.getElementById("prodgroupname");

	nameObj.value=name;
	idObj.value=id;

}
function popWindowsContactProd(){


    if(popwindow!=null) popwindow.close();
 	popwindow = window.open("../../masterdata/ogm/ProductbrandPopWindow.jsp?<%= OvalTools.randomURL() %>", "newwindow", "height=400, width=600,top=100,left=100,toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=yes")


 	//window.open("contactProdPopWindow.jsp?<%= OvalTools.randomURL() %>&isbottom=1&employeeid=<custom:write name="emplinfo" property="employeeid"/>", "newwindow", "height=400, width=600,top=100,left=100,toolbar=n0, menubar=no, scrollbars=yes, resizable=no, location=no, status=no")
}

function   cleanid(){

     idObj=document.getElementById("zmylprodgroupid");
    nameObj=document.getElementById("prodgroupname");

    if (isEmpty(nameObj.value)){
        idObj.value=" ";
    }
}
 var orgsettype = "";

function page_setOrg(id,name,code)
{
    if(orgsettype == "seller"){

       cform.sellerid.value = id;
       cform.sellername.value = name;
       
    }else{
      cform.buyerid.value = id;
      cform.buyername.value = name;
  }
}


function popWindowShowCityPage(){
	//var regioncode = document.cform.regioncode.value;
	var url = "AgreementCityPopcheckboxFrm.jsp?<%= OvalTools.randomURL() %>"+"&languagecode=<%=strLanguageCode%>"+"&clear=Y&viewflag=<%=viewflag%>&category=<custom:write name ="zmylagreementinfo" property="zmylagreementid" />";
	var windowAttribute = "height=600, width=700,top=40,left=100, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=yes";
  	if(popwindow!=null)
    popwindow.close();
  	popwindow = window.open(url,'hospitalinfo',windowAttribute);
}

function  reload_parentemp(){

 if( isEmpty(document.cform.zmylagreementconfigid.value))
   return;
 var  datahandler = new  DataHandler() ;

 datahandler.add_params("zmylagreementconfigid" , document.cform.zmylagreementconfigid.value,"Integer");
datahandler.getResultFromHashMap("zmylagreementconfiginfo" ,"sellertype" ,"document.cform.sellertype");
datahandler.getResultFromHashMap("zmylagreementconfiginfo" ,"buyertype" ,"document.cform.buyertype");
datahandler.getResultFromHashMap("zmylagreementconfiginfo" ,"startdate" ,"document.cform.startdate");
datahandler.getResultFromHashMap("zmylagreementconfiginfo" ,"expiredate" ,"document.cform.expiredate");
datahandler.getResultFromHashMap("zmylagreementconfiginfo" ,"startdate" ,"document.cform.startdates");
datahandler.getResultFromHashMap("zmylagreementconfiginfo" ,"expiredate" ,"document.cform.expiredates");
datahandler.getResultFromHashMap("zmylagreementconfiginfo" ,"datelastupdated" ,"document.cform.datelastupdateds");


 datahandler.add_function("clear_org()") ;
 datahandler.add_job("j_initagreementconfigeditmain") ;
 datahandler.runDataHandler ();
}

function  clear_org(){
   cform.sellerid.value="";
   cform.buyerid.value="";
    cform.sellername.value="";
    cform.buyername.value="";
}

function poporgprd(objecttype)
{
    var zmylagreementid = cform.zmylagreementid.value;
    var parentorgid= cform.buyerid.value ;
    var productgroupid= cform.productgroupid.value ;
 if (objecttype==4){
   window.open("AgreementOrgProd.jsp?<%= OvalTools.randomURL() %>&selectoption=agreement&zmylisseller=N&objecttype="+objecttype+"&parentorgid="+parentorgid+"&productgroupid="+productgroupid+"&zmylagreementid="+zmylagreementid+"&languagecode=<%= strLanguageCode %>", "newwindow", "height=2500, width=1000,top=100,left=100,toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no"); 
 }else {
  window.open("AgreementOrgProd.jsp?<%= OvalTools.randomURL() %>&selectoption=agreement&zmylisseller=N&objecttype="+objecttype+"&zmylagreementid="+zmylagreementid+"&productgroupid="+productgroupid+"&languagecode=<%= strLanguageCode %>", "newwindow", "height=2500, width=1000,top=100,left=100,toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no");
}
}

function popsellerchainorg()
{  
	var sellerid=document.cform.sellerid.value; //甲方
	if(isEmpty(sellerid)){
			alert("<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_FirstOrg",false)) %>");
			return;
	 }
	orgsettype = "buyer";
    var orgtype = cform.buyertype.value;
    if(orgtype == 99){
          orgtype="";
    } 
    window.open("../../zmyl/agreement/AgreementOrgSelect.jsp?<%= OvalTools.randomURL() %>&selectoption=agreement&zmylisseller=Y&objecttype=1&sellerid="+sellerid+"&zmylagreementconfigid="+orgtype+"&languagecode=<%= strLanguageCode %>", "newwindow", "height=250, width=600,top=100,left=100,toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no");
}

function popbuyerchainorg()
{  	
	var buyerid=document.cform.buyerid.value; //乙方
	if(isEmpty(buyerid)){
		alert("<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_SecondOrg",false)) %>");
		return;
    }
	orgsettype = "buyer";
    var orgtype = cform.buyertype.value;
    if(orgtype == 99){
          orgtype="";
    } 
    window.open("../../zmyl/agreement/AgreementOrgSelect.jsp?<%= OvalTools.randomURL() %>&selectoption=agreement&zmylisseller=Y&objecttype=1&buyerid="+buyerid+"&zmylagreementconfigid="+orgtype+"&languagecode=<%= strLanguageCode %>", "newwindow", "height=250, width=600,top=100,left=100,toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no");
}


function setOrg(id,name,code){
    cform.shortorgid.value = id;
    cform.shortorgname.value = name;
    cform.shortorgcode.value = code;
}


function popsellerorg()
{ 
	  var configid=document.cform.zmylagreementconfigid.value;
	  if(isEmpty(configid)){
			alert("<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_AgreementType",false)) %>");
			return;
	 }
	 orgsettype = "seller";
     var orgtype = cform.sellertype.value;
    if(orgtype == 99){
          orgtype="";
    }
    
  //window.open("../../masterdata/ogm/OrgSelect.jsp?<%= OvalTools.randomURL() %>&selectoption=agreement&zmylisseller=Y&objecttype=1&agreementconfigid="+cform.zmylagreementconfigid.value+"&zmylagreementconfigid="+orgtype+"&languagecode=<%= strLanguageCode %>", "newwindow", "height=250, width=600,top=100,left=100,toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no");
    
    window.open("../../zmyl/agreement/AgreementOrgSelect.jsp?<%= OvalTools.randomURL() %>&selectoption=agreementseller&zmylisseller=Y&objecttype=1&agreementconfigid="+cform.zmylagreementconfigid.value+"&zmylagreementconfigid="+orgtype+"&languagecode=<%= strLanguageCode %>", "newwindow", "height=250, width=600,top=100,left=100,toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no");
}
function popbuyerorg()
{  
	var configid=document.cform.zmylagreementconfigid.value;
	if(isEmpty(configid)){
			alert("<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_AgreementType",false)) %>");
			return;
	 }
	orgsettype = "buyer";
    var orgtype = cform.buyertype.value;
    if(orgtype == 99){
          orgtype="";
    } 
  //window.open("../../masterdata/ogm/OrgSelect.jsp?<%= OvalTools.randomURL() %>&selectoption=agreement&zmylisseller=N&objecttype=2&agreementconfigid="+cform.zmylagreementconfigid.value+"&zmylagreementconfigid="+orgtype+"&languagecode=<%= strLanguageCode %>", "newwindow", "height=250, width=600,top=100,left=100,toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no");

    window.open("../../zmyl/agreement/AgreementOrgSelect.jsp?<%= OvalTools.randomURL() %>&selectoption=agreementbuyer&zmylisseller=Y&objecttype=1&agreementconfigid="+cform.zmylagreementconfigid.value+"&zmylagreementconfigid="+orgtype+"&languagecode=<%= strLanguageCode %>", "newwindow", "height=250, width=600,top=100,left=100,toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no");
}

function page_setOrg2(id,name,code){
    cform.sellerid.value = id;
    cform.sellername.value = name;
    //cform.shortorgcode.value = code;
}

function page_setOrg3(id,name,code){
    cform.buyerid.value = id;
    cform.buyername.value = name;
    //cform.shortorgcode.value = code;
}

function page_approval()
{
	var frm = document.cform;
	 
	  frm.actionname.value = "approve";
	  frm.target = "_parent";
	  isRunning = true;
	  frm.submit();
}
function page_approve()
{
	window.parent.location.href="../../biee/ApprovalNotesFrm.jsp?<%= OvalTools.randomURL() %>&transactionid=<custom:write name="zmylagreementinfo" property="zmylagreementid"/>&transactioncode=<custom:write name="zmylagreementinfo" property="agreementcode"/>&subjectcode=813" ;
}

function popagreementprd()

{
	var zmylagreementconfigid=document.cform.zmylagreementconfigid.value;

	//alert(zmylagreementconfigid);
	if(isEmpty(zmylagreementconfigid)){
			alert("<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_AgreementType",false)) %>");
			return;
	 }
    var zmylagreementid = cform.zmylagreementid.value;
   
    var productgroupid= cform.productgroupid.value;

   window.open("AgreementProd.jsp?<%= OvalTools.randomURL() %>&selectoption=agreement&productgroupid="+productgroupid+"&zmylagreementid="+zmylagreementid+"&zmylagreementconfigid="+zmylagreementconfigid+"&viewflag=<%=viewflag%>&languagecode=<%= strLanguageCode %>", "newwindow", "height=2500, width=1000,top=100,left=100,toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no"); 

}
</script>

</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td class="summary_top"></td>
  </tr>
</table>
<table width="100%" cellspacing="0" cellpadding="0">
   <form name="cform" method="post" action="../../Dispatcher">
      <input type="hidden" name="pagename" value="p_agreementmain">
      <input type="hidden" name="actionname">
	<input type="hidden" name="subjectcode" value="813">

	<custom:hidden property="zmylagreementid"  name="zmylagreementinfo"  changedName="transactionid" />
	<custom:hidden property="agreementcode"  name="zmylagreementinfo"  changedName="transactioncode" />
	<input type="hidden" name="orgid">
      <input type="hidden" name="languagecode" value="<%= strLanguageCode %>">
	  <input type="hidden" name="isNew" value="<%= isNew %>">
	  <%if(isNew!=null && isNew.equals("Y")) { %>
	  	<input type="hidden" name="createdate" value="<%= OvalTools.getDate() %>">
	  	<custom:hidden name="userinfo" property="userid" scope="session" changedName="maker" />
	  		<custom:hidden name="userinfo" property="orgid" scope="session"  />
      
	  <%}%>
	  	 
      <input type="hidden" name="isdefault" value="<%= paraIsDefault %>">
      <custom:hidden name ="zmylagreementinfo" property="zmylagreementid" />

      



    <tr>
      <td valign="top">
        <table border="1" cellspacing="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" align="center" width="100%" cellpadding="1">
            
           
           <tr>
            <td colspan="4" class="deepblue-left" height="22"> <img src="../../images/<%= strLanguageCode %>/quote.gif">
            &nbsp;</td>
          </tr>
         <%	if(viewflag.equals("view")){%>
          <tr>

          <td class="td-text" width="110" ><%= label.getLabelName("L_ProtocolCode") + label.getLabelName("L_Colon") %></td>
          	<td>

                  <custom:write  name="zmylagreementinfo" property="agreementcode" />

               </td>
             <td class="td-text" width="110" ><%= label.getLabelName("L_ProtocolName") + label.getLabelName("L_Colon") %></td>
            <td>
				<custom:write  name="zmylagreementinfo" property="agreementname"  />
           	</td>
          </tr>
          <tr>
          <td  class="td-text" width="110" ><%= label.getLabelName("L_AgreementType") + label.getLabelName("L_Colon") %></td>
           	<td colspan="3" ><custom:select disabled="true" name="zmylagreementinfo" property="zmylagreementconfigid" optionsName="zmylagreementconfigsummary" command="notnull" label="L_AgreementType" optionValueKey="zmylagreementconfigid" optionInnerTextKey="agreementconfigname"  defaultValue="--------------" defaultValueCost=""/>
           	</td>
		 </tr>
          <tr>

           	<td  class="td-text" width="110" ><%= label.getLabelName("L_FirstOrg")  + label.getLabelName("L_Colon") %></td>
           	<td>
				  <oval:write name="zmylagreementinfo" property="sellername"/>
			</td>
            <td class="td-text" width="110" ><%= label.getLabelName("L_SecondOrg")  + label.getLabelName("L_Colon") %></td>
            <td>
                <oval:write name="zmylagreementinfo" property="buyername"/>
                <custom:hidden name="zmylagreementinfo" property="buyerid" command="notnull" label="L_SecondOrg" />
             </td>
             </tr>
             
             
            <tr>
           	<td  class="td-text" width="110" ><%=label.getLabelName("L_Protocols") +  label.getLabelName("L_ComSeller") + label.getLabelName("L_Colon") %></td>
           	<td>   <%if(zmylagreementinfo.get("zmylagreementid")!=null){       %>
				  <a onclick="poporgprd(1)"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>
                   <%}%>&nbsp;
            </td>
            <td class="td-text" width="110" ><%= label.getLabelName("L_Protocols") +  label.getLabelName("L_ComBuyer")  + label.getLabelName("L_Colon") %></td>
            <td> <%if(zmylagreementinfo.get("zmylagreementid")!=null){       %>
               <a onclick="poporgprd(2)"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>
                 <%}%>&nbsp;
            </td>

          </tr>
          
            <tr>
             <td  class="td-text" width="110" ><%=label.getLabelName("L_AgreementProduct")+ label.getLabelName("L_Colon") %></td>
           	  <td  colspan="3">&nbsp; <a onclick="popagreementprd()"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>
             </tr> 

			<%			 
			 if(zmylagreementinfo.get("shortorgname") != null ){
			%>         
          <tr>
           	<td  class="td-text" width="110" ><%=label.getLabelName("L_ISCHAIN") +  label.getLabelName("L_Store") + label.getLabelName("L_Colon") %></td>
           	<td colspan="3"><oval:write name="zmylagreementinfo" property="shortorgname"/></td>
          </tr>         
          <%} %>

          <tr>
            <td  class="td-text" width="110" ><%= label.getLabelName("L_ZMYLStartDate") + label.getLabelName("L_Colon") %></td>
           	<td><custom:write  property = "startdate" name="zmylagreementinfo"    dataType="date" dataFormatName="dateformat"/></td>
            <td class="td-text" width="110" ><%= label.getLabelName("L_ZMYLExpireDate") + label.getLabelName("L_Colon") %></td>
            <td><custom:write  property = "expiredate" name="zmylagreementinfo"    dataType="date" dataFormatName="dateformat"/></td>
          </tr>
			<tr>
			<td class="td-text" width="110" ><%= label.getLabelName("L_Protocols") +label.getLabelName("L_SalesScope") + label.getLabelName("L_Colon") %></td>
            <td><a onclick="popWindowShowCityPage()"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>
            </td>
            
             <td class="td-text" width="110" ><%= label.getLabelName("L_AgreementAmount") + label.getLabelName("L_Colon") %></td>
             <td >
                 &nbsp;<custom:write name="zmylagreementinfo" property="amount" /> 
            </td>
			</tr>
			
			 <tr>
             <td class="td-text" width="110" ><%= label.getLabelName("L_quartersales1") + label.getLabelName("L_Colon") %></td>
             <td >
                &nbsp; <custom:write name="zmylagreementinfo" property="quartersales1" /> 
            </td>
			<td class="td-text" width="110" ><%= label.getLabelName("L_quartersales2") + label.getLabelName("L_Colon") %></td>
             <td >
                 &nbsp;<custom:write name="zmylagreementinfo" property="quartersales2" /> 
            </td>
          
          </tr>
          
             <tr>
             <td class="td-text" width="110" ><%= label.getLabelName("L_quartersales3") + label.getLabelName("L_Colon") %></td>
             <td >
               &nbsp;  <custom:write name="zmylagreementinfo" property="quartersales3" /> 
            </td>
			<td class="td-text" width="110" ><%= label.getLabelName("L_quartersales4") + label.getLabelName("L_Colon") %></td>
             <td >
                &nbsp; <custom:write name="zmylagreementinfo" property="quartersales4" /> 
            </td>
          
          </tr>
            <tr>
            <td  class="td-text" width="110" ><%= label.getLabelName("L_SignDate") + label.getLabelName("L_Colon") %></td>
           	<td><custom:write  property = "signdate" name="zmylagreementinfo"    dataType="date" dataFormatName="dateformat"/></td>
            <td class="td-text" width="110" ><%= label.getLabelName("L_Maker") + label.getLabelName("L_Colon") %></td>
            <td> <custom:write  name="zmylagreementinfo" property="username"   /> </td>
            </tr>
			
          <tr>

           	<td class="td-text" width="110" ><%= label.getLabelName("L_CreateTime") + label.getLabelName("L_Colon") %></td>
           	<td>
				<custom:write name="zmylagreementinfo" property="createdate" dataType="date" dataFormatName="dateformat"/>
           	</td>
            <td class="td-text"  width="110" ><%= label.getLabelName("L_Status") + label.getLabelName("L_Colon") %></td>
            <td>
                <custom:write  dictType="Status"  name="zmylagreementinfo" property="status"   />
            </td>

          </tr>
          <tr>
          <td class="td-text"width="110" ><%= label.getLabelName("L_SupplementarySpecification") + label.getLabelName("L_Colon") %></td>
          <td colspan="3" ><custom:textarea readonly="true" name="zmylagreementinfo" property="comments" cols="120" rows="4" />
               </td>

          </tr>
			<custom:hidden name="zmylagreementconfiginfo" property="productgroupid" />

          <%}else{%>

          <tr>

          <td class="need" width="110" ><%= label.getLabelName("L_ProtocolCode") + label.getLabelName("L_Colon") %></td>
          	<td>
            <%if(isNew.equals("Y")){%>
                  <custom:text name="zmylagreementinfo" property="agreementcode" command="notnull"  label="L_ProtocolCode"/>
          	<%}else{%>
                  <custom:text  readonly="true" name="zmylagreementinfo" property="agreementcode" command="notnull"  label="L_ZMYLAgreementConfigCode"/>
           <%}%>
               </td>
             <td class="need" width="110" ><%= label.getLabelName("L_ProtocolName") + label.getLabelName("L_Colon") %></td>
            <td>
				<custom:text  name="zmylagreementinfo" property="agreementname" command="notnull"  size="20" label="L_ProtocolName" />
           	</td>
          </tr>
          <tr>

           	<td  class="need" width="110" ><%= label.getLabelName("L_AgreementType") + label.getLabelName("L_Colon") %></td>
           	<td  colspan="3">

                   <%if(zmylagreementinfo.get("zmylagreementid")!=null){       %>
                <custom:select disabled="true" changedName="readzmylagreementconfigid" name="zmylagreementinfo" property="zmylagreementconfigid" optionsName="zmylagreementconfigsummary"
                                   command="notnull" label="L_AgreementType" optionValueKey="zmylagreementconfigid"
                                   optionInnerTextKey="agreementconfigname"  defaultValue="--------------" defaultValueCost=""/>
                   <custom:hidden property="zmylagreementconfigid"  name="zmylagreementinfo"   />

 
                <%}else{%>
                      <custom:select name="zmylagreementinfo" property="zmylagreementconfigid" optionsName="zmylagreementconfigsummary"
                            onchange="reload_parentemp()"       command="notnull" label="L_AgreementType" optionValueKey="zmylagreementconfigid"
                                   optionInnerTextKey="agreementconfigname"  defaultValue="--------------" defaultValueCost=""/>
                                   
               <%}%>

            </td>
              
          </tr>
     
<tr>

           	<td  class="need" width="110" ><%= label.getLabelName("L_FirstOrg") + label.getLabelName("L_Colon") %></td>
            <td>
				  <custom:text name="zmylagreementinfo" property="sellername"></custom:text>
                                 <a onclick="popsellerorg()"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>
                                <custom:hidden name="zmylagreementinfo" property="sellerid" command="notnull" label="L_FirstOrg" />
                   <custom:hidden property="sellertype"  name="zmylagreementconfiginfo"   />
            </td>
            <td class="need" width="110" ><%= label.getLabelName("L_SecondOrg") + label.getLabelName("L_Colon") %></td>
            <td>
                <custom:text name="zmylagreementinfo" property="buyername"/>

                                 <a onclick="popbuyerorg()"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>
                                <custom:hidden name="zmylagreementinfo" property="buyerid" command="notnull" label="L_SecondOrg" />
                    <custom:hidden property="buyertype"  name="zmylagreementconfiginfo"   />
            </td>
          </tr>
           <tr>

           	<td  class="need" width="110" ><%=label.getLabelName("L_Protocols") +  label.getLabelName("L_ComSeller") + label.getLabelName("L_Colon") %></td>
           	<td>   <%if(zmylagreementinfo.get("zmylagreementid")!=null){       %>
				  <a onclick="poporgprd(1)"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>
                   <%}%>&nbsp;
            </td>
            <td class="need" width="110" ><%= label.getLabelName("L_Protocols") +  label.getLabelName("L_ComBuyer")  + label.getLabelName("L_Colon") %></td>
            <td> <%if(zmylagreementinfo.get("zmylagreementid")!=null){       %>
               <a onclick="poporgprd(2)"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>
                 <%}%>&nbsp;
            </td>

          </tr>
      <tr>
      	<%
				 HashMap zmylagreementconfiginfo = (HashMap)pageContext.getAttribute("zmylagreementconfiginfo");
				 if(zmylagreementconfiginfo == null)
				  {
					zmylagreementconfiginfo = new HashMap();
				  }
				 
				%>
				<%if(zmylagreementinfo.get("zmylagreementid")!=null){    if (zmylagreementconfiginfo.get("isbuyerchaintype")!=null){   %>
				 <% if (zmylagreementconfiginfo.get("isbuyerchaintype").equals("Y") ){%>
		<td  class="need" width="110" ><%=label.getLabelName("L_Protocols") +  label.getLabelName("L_ZMYLDistributors") + label.getLabelName("L_Colon") %></td>
           	 <td >&nbsp;
           	 <a onclick="poporgprd(3)"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>
      
            </td>  
            	<td  class="need" width="110" ><%=label.getLabelName("L_ISCHAIN") +  label.getLabelName("L_Store") + label.getLabelName("L_Colon") %></td>
           	<td > 
           	<a onclick="poporgprd(4)"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>

               </td>
                <%}} else {%> 
                 <td  class="need" width="110" ><%=label.getLabelName("L_Protocols") +  label.getLabelName("L_ZMYLDistributors") + label.getLabelName("L_Colon") %></td>
           	<td colspan="3">&nbsp; <a onclick="poporgprd(3)"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>
           	
              <%}%>
              <tr>
              <%if(zmylagreementinfo.get("zmylagreementid")!=null && zmylagreementinfo.get("zmylagreementconfigid")!=null){       %>
              <td  class="need" width="110" ><%=label.getLabelName("L_AgreementProduct")+ label.getLabelName("L_Colon") %></td>
           	  <td  colspan="3">&nbsp; <a onclick="popagreementprd()"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>
           	<%}else{ %>
           	<td  class="need" width="110" ><%=label.getLabelName("L_AgreementProduct")+ label.getLabelName("L_Colon") %></td>
           	<td  colspan="3">&nbsp;</td>
           	<%}%> 
              </tr>
            
				<%} else {%> 
				
              <td  class="need" width="110" ><%=label.getLabelName("L_Protocols") +  label.getLabelName("L_ZMYLDistributors") + label.getLabelName("L_Colon") %></td>
              <td >&nbsp;
              
             <td  class="need" width="110" ><%=label.getLabelName("L_AgreementProduct")+ label.getLabelName("L_Colon") %></td>
              <%if(zmylagreementinfo.get("zmylagreementid")!=null && zmylagreementinfo.get("zmylagreementconfigid")!=null){       %>
           	<td>&nbsp; <a onclick="popagreementprd()"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>
           			 <%}else{%>
           			 <td >&nbsp;</td>
           			   <%}%>
           	 <%}%>
           	 
	 </tr>
	  <tr>


			 <%
                SimpleDateFormat formatter1 = new SimpleDateFormat ("yyyy-MM-dd");
                String str_date_end=formatter1.format(new Date());
                
              %> 
              
        <td  class="need" width="110" ><%= label.getLabelName("L_ZMYLStartDate") + label.getLabelName("L_Colon") %></td>
	    <td>
                <custom:text property="startdate"  dataType="date"  module="IMG" size="15" name="zmylagreementinfo" command="notnull" label="L_ZMYLStartDate"/>
              <a onclick="javascript:c.show(this,'cform.startdate','yyyy-MM-dd');"><custom:button type="3" label="L_Asterisk" imgsrc="Time.gif" border="0"/></a>
        </td>
        <td class="need" width="110" ><%= label.getLabelName("L_ZMYLExpireDate") + label.getLabelName("L_Colon") %></td>
	    <td>
                <custom:text property="expiredate"  dataType="date"  module="IMG" size="15" name="zmylagreementinfo" command="notnull" label="L_ZMYLExpireDate"/>
              <a onclick="javascript:c.show(this,'cform.expiredate','yyyy-MM-dd');"><custom:button type="3" label="L_Asterisk" imgsrc="Time.gif" border="0"/></a>
        </td>
          </tr>
          
          <tr>
          	 <td class="need" width="110" ><%= label.getLabelName("L_Protocols") +label.getLabelName("L_SalesScope") + label.getLabelName("L_Colon") %></td>
             <td >

                 <%if(zmylagreementinfo.get("zmylagreementid")!=null){       %>
                  <a onclick="popWindowShowCityPage()"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>

                <%}else{%>
                    <a onclick="alert('<%= message.getMessageDesc("SAVE_INFO_FIRST") %>');"> <custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>
               <%}%>
            </td>
            
             <td class="need" width="110" ><%= label.getLabelName("L_AgreementAmount") + label.getLabelName("L_Colon") %></td>
             <td >
                 <custom:text name="zmylagreementinfo" property="amount" command="notnull"  label="L_AgreementAmount"/> 
            </td>
          </tr>
		
          <tr>
             <td class="need" width="110" ><%= label.getLabelName("L_quartersales1") + label.getLabelName("L_Colon") %></td>
             <td >
                 <custom:text name="zmylagreementinfo" property="quartersales1" command="notnull"  label="L_quartersales1"/> 
            </td>
			<td class="need" width="110" ><%= label.getLabelName("L_quartersales2") + label.getLabelName("L_Colon") %></td>
             <td >
                 <custom:text name="zmylagreementinfo" property="quartersales2" command="notnull"  label="L_quartersales2"/> 
            </td>
          
          </tr>
          
             <tr>
             <td class="need" width="110" ><%= label.getLabelName("L_quartersales3") + label.getLabelName("L_Colon") %></td>
             <td >
                 <custom:text name="zmylagreementinfo" property="quartersales3" command="notnull"  label="L_quartersales3"/> 
            </td>
			<td class="need" width="110" ><%= label.getLabelName("L_quartersales4") + label.getLabelName("L_Colon") %></td>
             <td >
                 <custom:text name="zmylagreementinfo" property="quartersales4" command="notnull"  label="L_quartersales4"/> 
            </td>
          
          </tr>
       
           <tr>
	        <td  class="need" width="110" ><%= label.getLabelName("L_SignDate") + label.getLabelName("L_Colon") %></td>
	        <td>
	               <custom:text property="signdate"  dataType="date"  module="IMG" size="15" name="zmylagreementinfo" command="notnull" label="L_SignDate"/>
	             <a onclick="javascript:c.show(this,'cform.signdate','yyyy-MM-dd');"><custom:button type="3" label="L_Asterisk" imgsrc="Time.gif" border="0"/></a>
	        </td>
        
            <td class="need" width="110" ><%= label.getLabelName("L_Maker") + label.getLabelName("L_Colon") %></td>
            <td>
                <%if(zmylagreementinfo.get("zmylagreementid")!=null){       %>
                 <oval:hidden name="zmylagreementinfo" property="maker"  />
                 <custom:write  name="zmylagreementinfo" property="username"   />

                <%}else{%>
                         <oval:hidden name="userinfo" property="userid" scope="session" changedName="maker" />
                    <oval:write name="userinfo" property="username" scope="session"   />
               <%}%>
            </td>
          </tr>
          <tr>

           	<td class="td-text" width="110" ><%= label.getLabelName("L_CreateTime") + label.getLabelName("L_Colon") %></td>
           	<td>
				<custom:write name="zmylagreementinfo" property="createdate" dataType="date" dataFormatName="dateformat"/>
           	</td>
            <td class="td-text"  width="110" ><%= label.getLabelName("L_Status") + label.getLabelName("L_Colon") %></td>
            <td>
                <custom:selectdic dictType="Status"  name="zmylagreementinfo" property="status"  valueCriteria="10"  />
            </td>

          </tr>
          <tr>
          <td class="td-text" width="110" ><%= label.getLabelName("L_SupplementarySpecification") + label.getLabelName("L_Colon") %></td>
          <td colspan="3" >

                <custom:textarea name="zmylagreementinfo" property="comments" cols="120" rows="4" />
               </td>

          </tr>
           <custom:hidden name="zmylagreementconfiginfo" property="startdates" />
             <custom:hidden name="zmylagreementconfiginfo" property="expiredates" />
             <custom:hidden name="zmylagreementconfiginfo" property="datelastupdateds" />
             <custom:hidden name="zmylagreementconfiginfo" property="productgroupid" />
          <%}%>

           
           
        </table>
      </td>
    </tr>
    <tr>
      <td class="summary_top"></td>
    </tr>
    <tr>
    <td height="49" class="td_center">
        <%if(zmylagreementinfo!=null && ((Integer)zmylagreementinfo.get("status")).intValue() == 10){%>
          <a onclick="page_submit()"><custom:button type="1" label="L_Submit1" imgsrc="back.gif" border="0" style="width:60" /></a>
          <%}%>
        <%if(zmylagreementinfo!=null && ((Integer)zmylagreementinfo.get("status")).intValue() == 20){%>
          <a onclick="page_approval()"><custom:button type="1" label="L_Check" imgsrc="back.gif" border="0" style="width:60" /></a>
          <%}%>
        <%if(!viewflag.equals("view")){%>
        <a onclick="page_save()"><custom:button type="1" label="L_Save" imgsrc="back.gif" border="0" style="width:60" /></a>
        <%}else {%>
      		<a onclick="javascript:page_approve()" target="_top"><custom:button type="1" label="L_Approve" imgsrc="back.gif" border="0" style="width:60" /> </a>  
		  <%}%>
		                                                                                                                                                                                                                          

        <a onclick="javascript:page_back()"><custom:button type="1" label="L_Back" imgsrc="back.gif" border="0" style="width:60"/></a>


    </td>
    </tr>
</form>
</table>
<script language="JavaScript" src="../../js/Calendar.js" ></script>
<%@include file="/inc/AlertError.inc"%>
</body>
</html>


           		